<template>
  <div>
    <!-- 顶部滑动条 -->
    <div id="slider" class="mui-slider ">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a class="mui-control-item mui-active" href="#item1mobile" data-wid="tab-top-subpage-1.html">
							推荐
						</a>
						<a class="mui-control-item" href="#item2mobile" data-wid="tab-top-subpage-2.html">
							热点
						</a>
						<a class="mui-control-item" href="#item3mobile" data-wid="tab-top-subpage-3.html">
							北京
						</a>
						<a class="mui-control-item" href="#item4mobile" data-wid="tab-top-subpage-4.html">
							社会
						</a>
						<a class="mui-control-item" href="#item5mobile" data-wid="tab-top-subpage-5.html">
							娱乐
						</a>
						<a class="mui-control-item" href="#item6mobile" data-wid="tab-top-subpage-6.html">
							科技
						</a>
					</div>
				</div>

			</div>
      <!-- 实现图片懒加载 -->
      <ul class="photo-list">
      <router-link v-for="item in list" :key="item.id" :to="'/home/photoinfo/' + item.id" tag="li">
        <!-- 模拟懒加载，实在是找不到数据了，只能用着本地的图片了。。。 -->
        <img v-lazy="'http://localhost:3000/src/images/0'+item.id+'.jpg'">
        <div class="info">
          <h1 class="info-title">{{ item.title }}</h1>
          <div class="info-body">{{ item.zhaiyao }}</div>
        </div>
      </router-link>
    </ul>
  </div>
</template>
<script>
// 导入mui.js
import mui from "../../lib/mui/js/mui.min.js";
export default {
  //操作元素时在mounted中进行，此时已经把dom结构渲染渲染好放到页面了，解决刷新可以滑动的问题
  mounted(){
     mui(".mui-scroll-wrapper").scroll({
      deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });
  },
  data(){
    return {
      list:[
        {id:'1',title:'123',zhaiyao:'你猜啊啊你猜啊啊你猜啊啊你猜啊啊你猜啊啊你猜啊啊你猜啊啊你猜啊啊你猜啊啊你猜啊啊你猜啊啊'},
        {id:'2',title:'456',zhaiyao:'噢噢噢噢'},
        {id:'3',title:'789',zhaiyao:'啦啦啦啦'},
        {id:'4',title:'101',zhaiyao:'大大大大'},
        {id:'5',title:'101',zhaiyao:'大大大大'},
        {id:'6',title:'101',zhaiyao:'大大大大'},
      ]
    }
  }

}
</script>
<style lang="scss" scoped>
  * {
    touch-action: pan-y;
  }
  .photo-list {
    list-style: none;
    margin: 0;
    padding: 10px;
    padding-bottom: 0;
    li {
        background-color: #ccc;
        text-align: center;
        margin-bottom: 10px;
        //盒阴影
        box-shadow: 0 0 9px #999;
        position: relative;
        img {
          width: 100%;
          vertical-align: middle;
        }
        img[lazy="loading"] {
          width: 40px;
          height: 300px;
          margin: auto;
        }
        .info {
          position: absolute;
          width: 100%;
          bottom: 0;
          color: white;
          text-align: left;
          background-color: rgba(0, 0, 0, 0.4);
          // 设置最高宽度
          max-height: 84px;
          .info-title {
            font-size: 14px;
          }
          .info-body {
            font-size: 13px;
          }
        }
  
    }
  }
</style>
